package com.lfs.dingtalk.robot.servcie;


import com.lfs.dingtalk.robot.domain.GroupChatSendRequest;

import java.util.HashMap;
import java.util.Map;

/**
 * 消息类型策略执行
 */
public class MessageTypeStrategyContext {
    private static final Map<Class<? extends GroupChatSendRequest.Type>, MessageStrategy> groupChatType = new HashMap<>();

    static {
        groupChatType.put(GroupChatSendRequest.Text.class, new MessageStrategy.TextMessageStrategy());
        groupChatType.put(GroupChatSendRequest.MarkDown.class, new MessageStrategy.MarkdownMessageStrategy());
    }

    public static MessageStrategy getStrategy(GroupChatSendRequest.Type messageType) {
        return groupChatType.get(messageType.getClass());
    }
}
